#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define uint unsigned int

#define YES cout << "Yes" << '\n'
#define NO cout << "No" << '\n'
#define endl '\n'
const int INF = 1e9;
const int MOD = 1;
using namespace std;
int gcd(int a, int b)
{
    a = abs(a);
    b = abs(b);
    if (a == 0)
        return b;
    if (b == 0)
        return a;
    if (a < 1000000 && b < 1000000)
    {
        int temp;
        while (b != 0)
        {
            temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
    int shift = 0;
    while (((a | b) & 1) == 0)
    {
        a >>= 1;
        b >>= 1;
        shift++;
    }
    while ((a & 1) == 0)
        a >>= 1;
    while (b != 0)
    {
        while ((b & 1) == 0)
            b >>= 1;
        if (a > b)
        {
            int temp = a;
            a = b;
            b = temp;
        }
        b = b - a;
    }
    return a << shift;
}
int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}
/*思考
二分
不要创建b数组:最大可达40G
*/

void solve()
{ll n, k, x;
    cin >> n >> k >> x;
    vector<int> a(n);
    for (ll i = 0; i < n; i++){
        cin >> a[i];
    }

    if (accumulate(a.begin(), a.end(), 0ll) * k < x){
        cout << 0 << '\n';
        return;
    }

    ll l = 1, r = n * k;
    while(l <= r){
        ll m = l + (r - l) / 2;
        int cnt_a = (n * k - m + 1) / n;
        int suff = (n * k - m + 1) % n;
        ll sum = cnt_a * accumulate(a.begin(), a.end(), 0ll);
        for (ll i = n - suff; i < n; i++){
            sum += a[i];
        }
        if (sum < x){
            r = m - 1;
        }
        else{
            l = m + 1;
        }
    }

    cout << r << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 0;
    cin >> t;
    while (t--)
        solve();
    return 0;
}